package com.cn.hotel.dao.Impl;

import com.cn.hotel.dao.IOrderDao;
import com.cn.hotel.model.OrderModel;
import com.cn.hotel.model.UserModel;
import com.cn.hotel.util.GetSqlSession;
import com.cn.hotel.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class OrderImpl implements IOrderDao {
    /**
     * 添加新的订单信息
     * @return
     */
    @Override
    public int add(OrderModel orderModel) {
        return GetSqlSession.getSqlSession().insert("com.cn.hotel.dao.IOrderDao.add",orderModel);
    }

    /**
     * 订单模糊查询 sql
     * @param orderModel
     * @return
     */
    @Override
    public List<OrderModel> findByKeyWord(OrderModel orderModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.IOrderDao.findByKeyWord",orderModel);
    }

    @Override
    public int getCount(OrderModel orderModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.IOrderDao.getCount",orderModel);
    }

    /**
     * 通过id查询
     * @param temp
     * @return
     */
    @Override
    public OrderModel findById(Integer temp) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.IOrderDao.findById",temp);
    }

    /**
     * 保存编辑
     * @param orderModel
     * @return
     */
    @Override
    public int orderEdit(OrderModel orderModel) {
        return GetSqlSession.getSqlSession().update("com.cn.hotel.dao.IOrderDao.orderEdit",orderModel);
    }
    //删除
    @Override
    public int delete(Integer temp) {
        return GetSqlSession.getSqlSession().delete("com.cn.hotel.dao.IOrderDao.delete",temp);
    }

}
